﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class Admin_FeedbackDetails : System.Web.UI.Page
{
    int CID = 3;
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void imgbAnswer_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["OPOConnectionString"].ToString());
        cnn.Open();
        SqlCommand cmd = new SqlCommand("Select Cust_Email from Customer where CustID = '" + CID + "'", cnn);
        SqlDataReader dread = cmd.ExecuteReader();
        string s = "";

        if (dread.Read())
            s = dread.GetString(0);

        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
        client.EnableSsl = true;
        client.Credentials = new NetworkCredential("f1101008s1@gmail.com", "student12345");
        using (MailMessage msg = new MailMessage())
        {
            msg.From = new MailAddress("f1101008s1@gmail.com");
            msg.To.Add(new MailAddress(s));
            msg.Subject = txtSubject.Text;
            msg.Body = txtAnswerFeedback.Text;
            client.Send(msg);
        }

        ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "ShowMessage()", true);
    }

    protected void imgbBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Feedback_Management.aspx");
    }

}